<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Org
 *
 * @author 耿鸿飞 <15911185633>
 */
class Resume_Org extends Model
{
    protected $tbl = 'resume_org';
    /**
     * 添加工作经历
     * @param type $uid
     * @param type $oid
     * @param type $jobtitle
     * @param type $desc
     * @param type $startdate
     * @param type $enddate
     * @return type
     */
    public function addOrg($uid,$oid,$jobtitle,$desc,$startdate,$enddate = null){
        $data = array(
            'Fuid' => $uid,
            'Foid' => $oid,
            'Fjobtitle' => $jobtitle,
            'Fdesc' => $desc,
            'Fstart' => $startdate,
            'Fend' => $enddate
        );
        return $this->insert($data);
    }
    /**
     * 修改工作经历
     * @param type $fid
     * @param type $oid
     * @param type $jobtitle
     * @param type $desc
     * @param type $startdate
     * @param type $enddate
     * @return type
     */
    public function editOrg($fid,$oid,$jobtitle,$desc,$startdate,$enddate = null){
        $data = array(
            'Foid' => $oid,
            'Fjobtitle' => $jobtitle,
            'Fdesc' => $desc,
            'Fstart' => $startdate,
            'Fend' => $enddate
        );
         return $this->update($data,sprintf("Fid=%d",$fid));
    }
    /**
     * 删除工作经历
     * @param type $fid
     * @return type
     */
    public function delOrg($fid){
        $data = array('Fstatus' => 'Del');
        return $this->update($data,sprintf("Fid=%d",$fid));
    }
    /**
     * 获取用户的全部工作经历
     * @param type $uid
     * @return type
     */
    public function getAll($uid){
        $rs = array();
        $sql = sprintf("SELECT * FROM %s WHERE Fuid=%d",$this->tbl,$uid);
        $list =  $this->getResults($sql);
        if($list){
            foreach($list AS $val){
                $rs[$val['Foid']] = $val;
            }
        }
        return $rs;
    }
}

?>
